package com.mixes.adapter;

import static com.mixes.field.FacebookField.*;
import static com.mixes.util.Utility.*;

import java.util.HashMap;
import java.util.LinkedList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.mixes.R;
import com.mixes.field.IField;

/**
 * TODO Auto-generated constructor stub
 * @author Author:
 * @version Revision:
 */
public class FacebookAdapter extends ArrayAdapter<HashMap<IField, Object>> {
    private LayoutInflater mInflater;

    public FacebookAdapter(Context context, LinkedList<HashMap<IField, Object>> list) {
        super(context, 0, list);
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        HashMap<IField, Object> item = getItem(position);

        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.facebook_list_item, null);

            holder.mProgressBar = customFindViewById(convertView, R.id.image_loading);

            holder.mProfileImage = customFindViewById(convertView, R.id.profile_image);

            holder.mDescription = customFindViewById(convertView, R.id.description);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.mDescription.setText(getHashmap(item, description));

        return convertView;
    }

    private class ViewHolder {
        ProgressBar mProgressBar;

        ImageView mProfileImage;

        TextView mName;

        TextView mScreenName;

        TextView mCreatedAt;

        TextView mDescription;

        TextView mTest;
    }
}
